@echo off

FOR /F "skip=2 tokens=2,*" %%A IN ('reg.exe query "HKLM\SOFTWARE\WOW6432Node\FileWave\WinClient" /v "fwUser"') DO set "fwClientName=%%B"

IF /I "%fwClientName%" == "%COMPUTERNAME%" (
exit 1
) ELSE (
wmic computersystem where name="%COMPUTERNAME%" call rename name="%fwClientName%"
%windir%\System32\shutdown.exe /r /t 60 /c "Computer renamed to %fwClientName%. Rebooting in 60 seconds." /f /d p:4:1
exit 2
)